Answer:

Yes.

Primitive Parameters

Often parameters are used to "fine-tune" the actions performed by a method. For example, imagine that you want to print only some of the elements of an array. Here is the ArrayOps class definition with a new method added:

import java.io.*;

class ArrayOps
{
  . . . . // other methods

  // print elements start through end
  void printRange ( int[] x, int start, int end )
  {
    for ( int  ;  ;  )
      System.out.print( x[index] + " " );
    System.out.println();
  }

}

class ArrayDemo
{
  public static void main ( String[] args ) 
  {
    ArrayOps operate = new ArrayOps();
    int[] ar1 =  { -20, 19, 1, 5, -1, 27, 19, 5 } ;
    
    // print elements at indexes 1, 2, 3, 4, 5
    operate.printRange( ar1, 1, 5 );
  }

}      

The method printRange() prints the elements from start to (and including) end. In this particular program, main() uses the method to print the elements at indexes 1 through 5. The values 19, 1, 5, -1, 27 are printed.

QUESTION 10:

Fill in the blanks for printRange(). Assume that start and end are legal indexes for the array.